<?php

declare(strict_types=1);

namespace App\CustHub\Request;

use App\Common\Traits\JsonStringCastTrait;
use Mine\MineFormRequest;

class RoomBroadcastSourceRequest extends MineFormRequest
{
    use JsonStringCastTrait;

    /**
     * 要自动解析的 JSON 字符串字段列表
     *
     * @var string[]
     */
    protected array $jsonFields = [
        'business_info',
    ];


    public function saveRules(): array
    {
        return [
            'name' => 'required|max:255',
            'type' => 'required|in:0,1,2',
            'wechat_type' => 'required_if:type,0|in:0,1',
            'room_id' => 'required_if:type,0',
            'listen_robot_id' => 'required_if:type,0',
            'speaker_ids' => 'required_if:type,0',
            'business_info' => 'required_if:type,0',
//            'share_account' => 'required',
        ];
    }

    public function detailRules(): array
    {
        return [
            'id' => 'required'
        ];
    }

    public function updateRules(): array
    {
        return array_merge(['id'=>'required'],$this->saveRules());
    }

    public function deleteRules(): array
    {
        return [
            'id' => 'required'
        ];
    }
}